<?xml version='1.0' encoding='UTF-8'?>
<manifest xmlns:android='http://schemas.android.com/apk/res/android'
          package='<%= @appPackageName %>'
          android:versionName='<%= @versionName %>'
          android:versionCode='<%= @versionCode %>'
          android:installLocation='<%= @installLocation %>'>

  <!-- Android SDK -->
  <uses-sdk android:minSdkVersion='<%= @minSdkVer %>' android:targetSdkVersion='<%= @targetSdkVer %>'
    <% if @maxSdkVer %>
      android:maxSdkVersion='<%= @maxSdkVer %>'
    <% end %>
  />

  <!-- Permission declarations -->
  <% @permissions.each do |name, protectionLevel| %>
  <permission android:name='<%=name%>' android:protectionLevel='<%=protectionLevel%>'/>
  <% end %>

  <!-- Uses permissions -->
  <% @usesPermissions.each do |name| %>
  <uses-permission android:name='<%=name%>'/>
  <% end %>


  <%# <!-- Installing the package -->
  <uses-permission android:name='android.permission.REQUEST_INSTALL_PACKAGES'/> %>

  <uses-permission android:name='android.permission.FOREGROUND_SERVICE'/>
  <uses-permission android:name='android.permission.FOREGROUND_SERVICE_SPECIAL_USE'/>

  <permission android:name="<%= @appPackageName %>.permission.RECEIVE_BROADCAST" android:protectionLevel="signature"/>

  <supports-screens android:smallScreens='true' android:normalScreens='true' android:largeScreens='true' android:xlargeScreens='true'/>
  <application android:requestLegacyExternalStorage='true'
    android:name='com.rhomobile.rhodes.RhodesApplication'
  <% if canRenderNetworkSecurityConfig %>
               android:networkSecurityConfig="@xml/network_security_config"
  <% end %>
               android:label='@string/app_name'
               android:icon='@mipmap/icon'
               android:debuggable='<%= @debuggable %>'
               android:allowBackup='<%= @allowBackup %>'>

    <!-- Uses libraries -->
    <% @usesLibraries.each do |name, isrequired| %>
    <uses-library android:name='<%=name%>'
    <% unless isrequired %>
      android:required='<%=isrequired%>'
    <% end %>
    />
    <% end %>

    <!-- Main activity -->
    <activity android:name='com.rhomobile.rhodes.RhodesActivity'
              android:label='@string/app_name'
              android:launchMode='singleTask'
              android:configChanges='orientation|screenSize|fontScale|smallestScreenSize|keyboard|keyboardHidden'
              android:screenOrientation='<%= @screenOrientation %>'
              android:exported='true'
              <% if @hardwareAcceleration %>
              android:hardwareAccelerated='true'
              <% end %> >
      <% @rhodesActivityIntentFilters.each do |filter| %>
        <%= makeIntentFilter(filter) %>
      <% end %>

    </activity>
    <activity android:name='com.rhomobile.rhodes.alert.PopupActivity' android:windowSoftInputMode='stateAlwaysHidden' android:theme='@style/PopupTheme' android:configChanges='orientation' android:screenOrientation='<%= @screenOrientation %>'/>
    <activity android:name='com.rhomobile.rhodes.ui.FileList' android:configChanges='orientation' android:screenOrientation='<%= @screenOrientation %>'/>
    <activity android:name='com.rhomobile.rhodes.camera.ImageCapture' android:windowSoftInputMode='stateAlwaysHidden' android:screenOrientation='landscape'/>
    <activity android:name='com.rhomobile.rhodes.datetime.DateTimePickerScreen' android:windowSoftInputMode='stateAlwaysHidden' android:configChanges='orientation' android:screenOrientation='<%= @screenOrientation %>'/>
    <activity android:name='com.rhomobile.rhodes.mapview.MapView' android:windowSoftInputMode='stateAlwaysHidden' android:configChanges='orientation' android:screenOrientation='<%= @screenOrientation %>'/>
    <activity android:name='com.rhomobile.rhodes.ui.LogViewDialog'  android:windowSoftInputMode='stateAlwaysHidden' android:configChanges='orientation' android:screenOrientation='<%= @screenOrientation %>'/>
    <service android:name='com.rhomobile.rhodes.RhodesService' android:exported='false' android:foregroundServiceType='specialUse' >
      <property android:name='android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE' android:value='Required to run API and components of RhoMobile platform.'/>
    </service>

    <% if  @androidVerMaj >= 7 %>
      <provider
        android:name='com.rhomobile.rhodes.RhoFileProvider'
        android:authorities='<%=@appPackageName%>.provider'
        android:exported='false'
        android:grantUriPermissions='true'>
        <meta-data
          android:name='android.support.FILE_PROVIDER_PATHS'
          android:resource='@xml/provider_paths' />
      </provider>
    <% else %>
      <provider android:name='com.rhomobile.rhodes.LocalFileProvider' android:authorities='<%=@appPackageName%>' android:grantUriPermissions='false' <%= @androidVerMaj >= 7 ? "android:exported='true'" : "android:exported='false'" %> >
        <grant-uri-permission android:pathPrefix='/rhodes/apps/'/>
        <grant-uri-permission android:pathPrefix='/rhodata/apps/'/>
      </provider>
    <% end %>



	<receiver android:name='com.rho.notification.AlarmReceiver' android:enabled="false" android:exported='true'>
     <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
     </intent-filter>
    </receiver>

    <!-- application tag addon templates from extensions -->
    <% @applicationManifestAdds.each do |extAdd| %>
      <%=render extAdd%>
    <% end %>

  </application>

  <!-- manifest tag addon templates from extensions-->
  <% @manifestManifestAdds.each do |extAdd| %>
    <%=render extAdd%>
  <% end %>

</manifest>
